﻿Imports System.Data
Imports System.Web.Services
Imports System.Configuration
Imports System.Data.SqlClient

Public Class ClubList
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        AddButtonIcon(phSearchButton, btnSearch, "glyphicon glyphicon-search")

        If Not IsPostBack Then
            If (gvClubList.Rows.Count = 0) Then
                phSearch.Visible = False
                gvClubList.Visible = False
                pnlUserMessage_Error.Visible = True
                lblUserMessage_Error.Text = "No clubs were added yet"
            End If
        End If
    End Sub

    Protected Sub btnAddNewClub_Click(sender As Object, e As EventArgs) Handles btnAddNewClub.Click
        Response.Redirect("~/AddClub.aspx")
    End Sub

    Protected Sub btnRSSFeed_Click(sender As Object, e As EventArgs) Handles btnRSSFeed.Click
        Response.Redirect("~/Feeds/ClubListFeed.aspx")
    End Sub

    Private Sub AddButtonIcon(ph As PlaceHolder, btn As Button, IconClass As String, Optional CustomLabelStyle As String = "")

        If btn.Visible = False Then Exit Sub
        Dim g As New HtmlGenericControl
        g.ID = "labelFor_" + btn.ID
        g.TagName = "label"
        g.Attributes.Add("for", btn.ClientID)
        g.Attributes.Add("class", "" + btn.CssClass + "")
        If Not CustomLabelStyle = "" Then g.Attributes.Add("style", CustomLabelStyle)
        g.InnerHtml = "<i class=""" + IconClass + """></i> " + btn.Text
        ph.Controls.Add(g)
        btn.Attributes.Add("style", "display:none;")

    End Sub

End Class